from typing import TypedDict,Annotated
from langgraph.graph import START,END,StateGraph
from operator import add

class State(TypedDict):
    foo:Annotated[list[int],add]


def agent_01(state):
    return {'foo':[state['foo'][-1] + 1]}

def condi(state):
    if state['foo'][-1]>18:
        return END
    else:
        return "node_01"

builder = StateGraph(State)
builder.add_node("node_01",agent_01)
builder.add_edge(START,"node_01")
builder.add_conditional_edges("node_01",condi,{"node_01":"node_01",END:END})
graph = builder.compile()

r = graph.invoke({'foo':[10]})
print(r)